--- title: OpenHSI Class keywords: fastai sidebar: home_sidebar summary: "The bridge between camera implementations and the rest of `openhsi` land." description: "The bridge between camera implementations and the rest of `openhsi` land." nb_path: "nbs/01_capture.ipynb" ---
{% include warning.html content='Running in notebook slow downs the camera more than running in a script. ' %}
To add a custom camera, five methods need to be defined in a class to:
__init__, andstart_cam, andstop_cam, andget_img, andset_exposure, andget_temp.By inheriting from the OpenHSI class, all the methods to load settings/calibration files, collect datacube, saving data to NetCDF, and viewing as RGB are integrated. Furthermore, the custom camera class can be passed to a SettingsBuilder class for calibration.
For example, we implement a simulated camera below.
with SimulatedCamera(img_path="assets/great_hall_slide.png", n_lines=1028, processing_lvl = 3,
json_path="assets/cam_settings.json",pkl_path="assets/cam_calibration.pkl") as cam:
cam.collect()
fig = cam.show(plot_lib="matplotlib",hist_eq=True)
fig.opts(fig_inches=7,title="simulated hyperspectral datacube")
Each RGB value is converted into a pseudo-spectra by using the CIE XYZ matching functions.
json_path = '../calibration_files/OpenHSI-16_settings_Mono8_bin2.json'
pkl_path = '../calibration_files/OpenHSI-16_calibration_Mono8_bin2_window.pkl'
proc_dc = ProcessRawDatacube(fname = "../../Downloads/16_pvn1_bin2_10ms2022_01_13-04_22_25.nc", processing_lvl=4,
json_path=json_path, pkl_path=pkl_path)
proc_dc.collect()
fig = proc_dc.show(hist_eq=True)
fig
If your saved datacubes have already been processed (for example, binned for smaller file size), you can further post-process your datacube using ProcessDatacube. A list of callable transforms can be provided to ProcessDatacube.load_next_tfms, the catch is to remember what transforms have already been applied during data collection and the final desired processing level (binning, radiance output, ...). See the quick start guide for some documentation on what is done for each processing level.
{% include warning.html content='next_tfms needs to be valid. For instance, you cannot bin twice!' %}
proced_dc = ProcessDatacube(fname = "../calibration_files/2022_01_13/2022_01_13-04_22_25_proc_lvl_2.nc", processing_lvl=4,
json_path=json_path, pkl_path=pkl_path)
proced_dc.load_next_tfms([proc_dc.dn2rad])
proced_dc.collect()
proced_dc.show(hist_eq=True)